package com.orange.lockscreen.layers.finger;

import android.content.Context;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.widget.RelativeLayout;

import com.orange.lockscreen.R;

public class CircleSlat extends RelativeLayout {

	private ImageView	mFirstCircle;
	private ImageView	mSecondCircle;

	private int			mX;
	private int			mY;

	public CircleSlat(Context context) {
		super(context);
		init(context);
	}

	private void init(Context context) {
		mFirstCircle = new ImageView(getContext());
		mFirstCircle.setImageResource(R.drawable.ic_first_circle);
		mFirstCircle.setScaleType(ScaleType.CENTER);
		mFirstCircle.setVisibility(INVISIBLE);
		addView(mFirstCircle);

		mSecondCircle = new ImageView(getContext());
		mSecondCircle.setImageResource(R.drawable.ic_first_circle);
		mSecondCircle.setScaleType(ScaleType.CENTER);
		mSecondCircle.setVisibility(INVISIBLE);
		addView(mSecondCircle);
	}

	@Override
	protected void onLayout(boolean changed, int l, int t, int r, int b) {
		int width = mFirstCircle.getMeasuredWidth();
		int height = mFirstCircle.getMeasuredHeight();
		int ll = (int) (mX - (width / 2.0));
		int tt = (int) (mY - (height / 2.0));
		mFirstCircle.layout(ll, tt, ll + width, tt + height);
		mSecondCircle.layout(ll, tt, ll + width, tt + height);
	}

	public ImageView getFirstCircleView() {
		return mFirstCircle;
	}

	public ImageView getSecondCircleView() {
		return mSecondCircle;
	}

	public void setCirclePosition(int x, int y) {
		mX = x;
		mY = y;
	}
}
